#pragma once

#include "../../external/iselfcontrol.h"
#include "../mage.h"
#include "arrays.h"

class SelfControl : public virtual ISelfControl
{
public:
    SelfControl(const Mage * mage,
                const UnitsArray *units,
                const SpellsArray *spells,
                const BonusesArray *bonuses);
    ~SelfControl();

    // ISelfControl interface
    const IUnitsArray *getVisibleUnits() const;
    const ISpellsArray *getVisibleSpells() const;
    const IBonusesArray *getVisibleBonuses() const;

    void boost(float delta);
    float getMaxBoostDelta() const;
    void rotate(float delta);
    float getMaxRotationDelta() const;
    void act(Action action);

    // IUnit interface
    int health() const;
    int mana() const;
    const IEffectsArray *effects() const;
    float speed() const;
    float direction() const;
    float speedX() const;
    float speedY() const;
    float x() const;
    float y() const;

    // own interface
    float getBoostDelta() const;
    float getRotationDelta() const;
    Action action() const;

private:
    static const float MAX_BOOST_DELTA;
    static const float MAX_ROT_DELTA;

    const Mage *_mage;
    const UnitsArray *_visibleUnits;
    const SpellsArray *_visibleSpells;
    const BonusesArray *_visibleBonuses;

    Action _action;
    float _boostDelta;
    float _rotDelta;
};
